package com.chinastock.config;

import com.chinastock.log.PerfLogInterceptor;
import com.chinastock.log.TraceInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@ConditionalOnProperty(prefix = "web.log",value = "enabled",matchIfMissing = true)
@Configuration
public class LogConfig  implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TraceInterceptor()).addPathPatterns("/**");
        registry.addInterceptor(new PerfLogInterceptor()).addPathPatterns("/**");
    }
}
